﻿
namespace Service
{
	using System;
	using Data.Repository;
	using System.Linq;
	using System.Collections.Generic;

	public class StateProvinceService : IStateProvinceService
	{
		private IStateProvinceRepository _stateProvinceRepository;

		#region IStateProvinceService Members

		public int CreateNewStateProvince(Data.Entity.StateProvince theNewStateProvince)
		{
			if (theNewStateProvince == null)
			{
				return 0;
			}

			throw new NotImplementedException();
		}

		public IList<Data.Entity.StateProvince> GetStateProvinceByCountry(int countryID)
		{
			if (countryID <= 0)
			{
				return null;
			}

			if (_stateProvinceRepository == null)
			{
				_stateProvinceRepository = new StateProvinceRepository();
			}

			return _stateProvinceRepository.GetStateProvinceByCountry(countryID);
		}

		public IList<Data.Entity.City> GetCityByStateProvince(int stateProvinceID)
		{
			if (stateProvinceID <= 0)
			{
				return null;
			}

			if (_stateProvinceRepository == null)
			{
				_stateProvinceRepository = new StateProvinceRepository();
			}

			return _stateProvinceRepository.GetCityByStateProvince(stateProvinceID);
		}

		public IList<Data.Entity.StateProvince> GetAllStateProvince()
		{
			if (_stateProvinceRepository == null)
			{
				_stateProvinceRepository = new StateProvinceRepository();
			}

			return _stateProvinceRepository.GetAllStateProvince();
		}

		public IList<Data.Entity.City> GetAllCity()
		{
			if (_stateProvinceRepository == null)
			{
				_stateProvinceRepository = new StateProvinceRepository();
			}

			return _stateProvinceRepository.GetAllCity();
		}

		#endregion
	}
}
